<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: Storage   Storage.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
	<link rel="stylesheet" type="text/css" href="assets/api.css" />

    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
        <h3>Storage&nbsp; <span class="subtitle">2.8.0r4</span></h3>
        <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> 
            &gt; <a href="./module_storage.html" title="Storage">Storage</a>
                
                 &gt; Storage.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
                        <div class="highlight" ><pre><span class="c">/**</span>
<span class="c"> * The Storage module manages client-side data storage.</span>
<span class="c"> * @module Storage</span>
<span class="c"> */</span>

<span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>

	<span class="c">// internal shorthand</span>
<span class="c"></span><span class="k">var</span> <span class="nx">Y</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">,</span>
	<span class="nx">YU</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">util</span><span class="o">,</span>
	<span class="nx">YL</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">lang</span><span class="o">,</span>
	<span class="nx">_logOverwriteError</span><span class="o">;</span>

<span class="k">if</span> <span class="o">(!</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">Storage</span><span class="o">)</span> <span class="o">{</span>
	<span class="nx">_logOverwriteError</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">fxName</span><span class="o">)</span> <span class="o">{</span>
		<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;Exception in YAHOO.util.Storage.?? - must be extended by a storage engine&#39;</span><span class="o">.</span><span class="nx">replace</span><span class="o">(</span><span class="s1">&#39;??&#39;</span><span class="o">,</span> <span class="nx">fxName</span><span class="o">).</span><span class="nx">replace</span><span class="o">(</span><span class="s1">&#39;??&#39;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">getName</span> <span class="o">?</span> <span class="k">this</span><span class="o">.</span><span class="nx">getName</span><span class="o">()</span> <span class="o">:</span> <span class="s1">&#39;Unknown&#39;</span><span class="o">),</span> <span class="s1">&#39;error&#39;</span><span class="o">);</span>
	<span class="o">};</span>

	<span class="c">/**</span>
<span class="c">	 * The Storage class is an HTML 5 storage API clone, used to wrap individual storage implementations with a common API.</span>
<span class="c">	 * @class Storage</span>
<span class="c">	 * @namespace YAHOO.util</span>
<span class="c">	 * @constructor</span>
<span class="c">	 * @param location {String} Required. The storage location.</span>
<span class="c">	 * @parm name {String} Required. The engine name.</span>
<span class="c">	 * @param conf {Object} Required. A configuration object.</span>
<span class="c">	 */</span>
	<span class="nx">YU</span><span class="o">.</span><span class="nx">Storage</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">location</span><span class="o">,</span> <span class="nx">name</span><span class="o">,</span> <span class="nx">conf</span><span class="o">)</span> <span class="o">{</span>
		<span class="k">var</span> <span class="nx">that</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
		<span class="nx">Y</span><span class="o">.</span><span class="nx">env</span><span class="o">.</span><span class="nx">_id_counter</span> <span class="o">+=</span> <span class="m">1</span><span class="o">;</span>

		<span class="c">// protected variables</span>
<span class="c"></span>		<span class="nx">that</span><span class="o">.</span><span class="nx">_cfg</span> <span class="o">=</span> <span class="nx">YL</span><span class="o">.</span><span class="nx">isObject</span><span class="o">(</span><span class="nx">conf</span><span class="o">)</span> <span class="o">?</span> <span class="nx">conf</span> <span class="o">:</span> <span class="o">{};</span>
		<span class="nx">that</span><span class="o">.</span><span class="nx">_location</span> <span class="o">=</span> <span class="nx">location</span><span class="o">;</span>
		<span class="nx">that</span><span class="o">.</span><span class="nx">_name</span> <span class="o">=</span> <span class="nx">name</span><span class="o">;</span>
		<span class="nx">that</span><span class="o">.</span><span class="nx">isReady</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

		<span class="c">// public variables</span>
<span class="c"></span>		<span class="nx">that</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="nx">that</span><span class="o">.</span><span class="nx">CE_READY</span><span class="o">,</span> <span class="o">{</span><span class="nx">scope</span><span class="o">:</span> <span class="nx">that</span><span class="o">});</span>
		<span class="nx">that</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="nx">that</span><span class="o">.</span><span class="nx">CE_CHANGE</span><span class="o">,</span> <span class="o">{</span><span class="nx">scope</span><span class="o">:</span> <span class="nx">that</span><span class="o">});</span>
		
		<span class="nx">that</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="nx">that</span><span class="o">.</span><span class="nx">CE_READY</span><span class="o">,</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
			<span class="nx">that</span><span class="o">.</span><span class="nx">isReady</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
		<span class="o">});</span>
	<span class="o">};</span>

	<span class="nx">YU</span><span class="o">.</span><span class="nx">Storage</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="o">{</span>

		<span class="c">/**</span>
<span class="c">		 * The event name for when the storage item is ready.</span>
<span class="c">		 * @property CE_READY</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">CE_READY</span><span class="o">:</span> <span class="s1">&#39;YUIStorageReady&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The event name for when the storage item has changed.</span>
<span class="c">		 * @property CE_CHANGE</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">CE_CHANGE</span><span class="o">:</span> <span class="s1">&#39;YUIStorageChange&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The delimiter uesed between the data type and the data.</span>
<span class="c">		 * @property DELIMITER</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">DELIMITER</span><span class="o">:</span> <span class="s1">&#39;__&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The configuration of the engine.</span>
<span class="c">		 * @property _cfg</span>
<span class="c">		 * @type {Object}</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_cfg</span><span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The name of this engine.</span>
<span class="c">		 * @property _name</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_name</span><span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The location for this instance.</span>
<span class="c">		 * @property _location</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_location</span><span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * The current length of the keys.</span>
<span class="c">		 * @property length</span>
<span class="c">		 * @type {Number}</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">length</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * This engine singleton has been initialized already.</span>
<span class="c">		 * @property isReady</span>
<span class="c">		 * @type {String}</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">isReady</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>

		<span class="c">/**</span>
<span class="c">		 * Clears any existing key/value pairs.</span>
<span class="c">		 * @method clear</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">clear</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">_clear</span><span class="o">();</span>
			<span class="k">this</span><span class="o">.</span><span class="nx">length</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Fetches the data stored and the provided key.</span>
<span class="c">		 * @method getItem</span>
<span class="c">		 * @param key {String} Required. The key used to reference this value (DOMString in HTML 5 spec).</span>
<span class="c">		 * @return {String|NULL} The value stored at the provided key (DOMString in HTML 5 spec).</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">getItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Fetching item at  &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="o">);</span>
			<span class="k">var</span> <span class="nx">item</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItem</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
			<span class="k">return</span> <span class="nx">YL</span><span class="o">.</span><span class="nx">isValue</span><span class="o">(</span><span class="nx">item</span><span class="o">)</span> <span class="o">?</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getValue</span><span class="o">(</span><span class="nx">item</span><span class="o">)</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span> <span class="c">// required by HTML 5 spec</span>
<span class="c"></span>		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Fetches the storage object&#39;s name; should be overwritten by storage engine.</span>
<span class="c">		 * @method getName</span>
<span class="c">		 * @return {String} The name of the data storage object.</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">getName</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span><span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_name</span><span class="o">;},</span>

		<span class="c">/**</span>
<span class="c">		 * Tests if the key has been set (not in HTML 5 spec); should be overwritten by storage engine.</span>
<span class="c">		 * @method hasKey</span>
<span class="c">		 * @param key {String} Required. The key to search for.</span>
<span class="c">		 * @return {Boolean} True when key has been set.</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">hasKey</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">return</span> <span class="nx">YL</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_hasKey</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Retrieve the key stored at the provided index; should be overwritten by storage engine.</span>
<span class="c">		 * @method key</span>
<span class="c">		 * @param index {Number} Required. The index to retrieve (unsigned long in HTML 5 spec).</span>
<span class="c">		 * @return {String} Required. The key at the provided index (DOMString in HTML 5 spec).</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">key</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Fetching key at &quot;</span> <span class="o">+</span> <span class="nx">index</span><span class="o">);</span>

			<span class="k">if</span> <span class="o">(</span><span class="nx">YL</span><span class="o">.</span><span class="nx">isNumber</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">-</span><span class="m">1</span> <span class="o">&lt;</span> <span class="nx">index</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
				<span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_key</span><span class="o">(</span><span class="nx">index</span><span class="o">);</span>
				<span class="k">if</span> <span class="o">(</span><span class="nx">value</span><span class="o">)</span> <span class="o">{</span><span class="k">return</span> <span class="nx">value</span><span class="o">;}</span>
			<span class="o">}</span>

			<span class="c">// this is thrown according to the HTML5 spec</span>
<span class="c"></span>			<span class="k">throw</span><span class="o">(</span><span class="s1">&#39;INDEX_SIZE_ERR - Storage.setItem - The provided index (&#39;</span> <span class="o">+</span> <span class="nx">index</span> <span class="o">+</span> <span class="s1">&#39;) is not available&#39;</span><span class="o">);</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Remove an item from the data storage.</span>
<span class="c">		 * @method setItem</span>
<span class="c">		 * @param key {String} Required. The key to remove (DOMString in HTML 5 spec).</span>
<span class="c">		 * @public</span>
<span class="c">		 */</span>
		<span class="nx">removeItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;removing &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="o">);</span>
			
			<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasKey</span><span class="o">(</span><span class="nx">key</span><span class="o">))</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">oldValue</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItem</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
                <span class="k">if</span> <span class="o">(!</span> <span class="nx">oldValue</span><span class="o">)</span> <span class="o">{</span><span class="nx">oldValue</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;}</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_removeItem</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
				<span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CE_CHANGE</span><span class="o">,</span> <span class="k">new</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">StorageEvent</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">key</span><span class="o">,</span> <span class="nx">oldValue</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">StorageEvent</span><span class="o">.</span><span class="nx">TYPE_REMOVE_ITEM</span><span class="o">));</span>
			<span class="o">}</span>
			<span class="k">else</span> <span class="o">{</span>
				<span class="c">// HTML 5 spec says to do nothing</span>
<span class="c"></span>			<span class="o">}</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Adds an item to the data storage.</span>
<span class="c">		 * @method setItem</span>
<span class="c">		 * @param key {String} Required. The key used to reference this value (DOMString in HTML 5 spec).</span>
<span class="c">		 * @param data {Object} Required. The data to store at key (DOMString in HTML 5 spec).</span>
<span class="c">		 * @public</span>
<span class="c">		 * @throws QUOTA_EXCEEDED_ERROR</span>
<span class="c">		 */</span>
		<span class="nx">setItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">data</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;SETTING &quot;</span> <span class="o">+</span> <span class="nx">data</span> <span class="o">+</span> <span class="s2">&quot; to &quot;</span> <span class="o">+</span> <span class="nx">key</span><span class="o">);</span>
			
			<span class="k">if</span> <span class="o">(</span><span class="nx">YL</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">key</span><span class="o">))</span> <span class="o">{</span>
				<span class="k">var</span> <span class="nx">eventType</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">hasKey</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">?</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">StorageEvent</span><span class="o">.</span><span class="nx">TYPE_UPDATE_ITEM</span> <span class="o">:</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">StorageEvent</span><span class="o">.</span><span class="nx">TYPE_ADD_ITEM</span><span class="o">,</span>
					<span class="nx">oldValue</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItem</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
				<span class="k">if</span> <span class="o">(!</span> <span class="nx">oldValue</span><span class="o">)</span> <span class="o">{</span><span class="nx">oldValue</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;}</span>

				<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_setItem</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_createValue</span><span class="o">(</span><span class="nx">data</span><span class="o">)))</span> <span class="o">{</span>
					<span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">CE_CHANGE</span><span class="o">,</span> <span class="k">new</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">StorageEvent</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">key</span><span class="o">,</span> <span class="nx">oldValue</span><span class="o">,</span> <span class="nx">data</span><span class="o">,</span> <span class="nx">eventType</span><span class="o">));</span>
				<span class="o">}</span>
				<span class="k">else</span> <span class="o">{</span>
					<span class="c">// this is thrown according to the HTML5 spec</span>
<span class="c"></span>					<span class="k">throw</span><span class="o">(</span><span class="s1">&#39;QUOTA_EXCEEDED_ERROR - Storage.setItem - The choosen storage method (&#39;</span> <span class="o">+</span>
						  <span class="k">this</span><span class="o">.</span><span class="nx">getName</span><span class="o">()</span> <span class="o">+</span> <span class="s1">&#39;) has exceeded capacity&#39;</span><span class="o">);</span>
				<span class="o">}</span>
			<span class="o">}</span>
			<span class="k">else</span> <span class="o">{</span>
				<span class="c">// HTML 5 spec says to do nothing</span>
<span class="c"></span>			<span class="o">}</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Implementation of the clear login; should be overwritten by storage engine.</span>
<span class="c">		 * @method _clear</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_clear</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
			<span class="nx">_logOverwriteError</span><span class="o">(</span><span class="s1">&#39;_clear&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Converts the object into a string, with meta data (type), so it can be restored later.</span>
<span class="c">		 * @method _createValue</span>
<span class="c">		 * @param s {Object} Required. An object to store.</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_createValue</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">s</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">var</span> <span class="nx">type</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YL</span><span class="o">.</span><span class="nx">isNull</span><span class="o">(</span><span class="nx">s</span><span class="o">)</span> <span class="o">||</span> <span class="nx">YL</span><span class="o">.</span><span class="nx">isUndefined</span><span class="o">(</span><span class="nx">s</span><span class="o">))</span> <span class="o">?</span> <span class="o">(</span><span class="s1">&#39;&#39;</span> <span class="o">+</span> <span class="nx">s</span><span class="o">)</span> <span class="o">:</span> <span class="k">typeof</span> <span class="nx">s</span><span class="o">;</span>
			<span class="k">return</span> <span class="s1">&#39;string&#39;</span> <span class="o">===</span> <span class="nx">type</span> <span class="o">?</span> <span class="nx">s</span> <span class="o">:</span> <span class="nx">type</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">DELIMITER</span> <span class="o">+</span> <span class="nx">s</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Implementation of the getItem login; should be overwritten by storage engine.</span>
<span class="c">		 * @method _getItem</span>
<span class="c">		 * @param key {String} Required. The key used to reference this value.</span>
<span class="c">		 * @return {String|NULL} The value stored at the provided key.</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_getItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">_logOverwriteError</span><span class="o">(</span><span class="s1">&#39;_getItem&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Converts the stored value into its appropriate type.</span>
<span class="c">		 * @method _getValue</span>
<span class="c">		 * @param s {String} Required. The stored value.</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_getValue</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">s</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">s</span> <span class="o">?</span> <span class="nx">s</span><span class="o">.</span><span class="nx">split</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">DELIMITER</span><span class="o">)</span> <span class="o">:</span> <span class="o">[];</span>
			<span class="k">if</span> <span class="o">(</span><span class="m">1</span> <span class="o">==</span> <span class="nx">a</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span><span class="k">return</span> <span class="nx">s</span><span class="o">;}</span>

			<span class="nx">switch</span> <span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">])</span> <span class="o">{</span>
				<span class="nx">case</span> <span class="s1">&#39;boolean&#39;</span><span class="o">:</span> <span class="k">return</span> <span class="s1">&#39;true&#39;</span> <span class="o">===</span> <span class="nx">a</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
				<span class="nx">case</span> <span class="s1">&#39;number&#39;</span><span class="o">:</span> <span class="k">return</span> <span class="nb">parseFloat</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">1</span><span class="o">]);</span>
				<span class="nx">case</span> <span class="s1">&#39;null&#39;</span><span class="o">:</span> <span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
				<span class="nx">default</span><span class="o">:</span> <span class="k">return</span> <span class="nx">a</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
			<span class="o">}</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Implementation of the key logic; should be overwritten by storage engine.</span>
<span class="c">		 * @method _key</span>
<span class="c">		 * @param index {Number} Required. The index to retrieve (unsigned long in HTML 5 spec).</span>
<span class="c">		 * @return {String|NULL} Required. The key at the provided index (DOMString in HTML 5 spec).</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_key</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">_logOverwriteError</span><span class="o">(</span><span class="s1">&#39;_key&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/*</span>
<span class="c">		 * Implementation to fetch evaluate the existence of a key.</span>
<span class="c">		 * @see YAHOO.util.Storage._hasKey</span>
<span class="c">		 */</span>
		<span class="nx">_hasKey</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="k">return</span> <span class="kc">null</span> <span class="o">!==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getItem</span><span class="o">(</span><span class="nx">key</span><span class="o">);</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Implementation of the removeItem login; should be overwritten by storage engine.</span>
<span class="c">		 * @method _removeItem</span>
<span class="c">		 * @param key {String} Required. The key to remove.</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_removeItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">_logOverwriteError</span><span class="o">(</span><span class="s1">&#39;_removeItem&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
		<span class="o">},</span>

		<span class="c">/**</span>
<span class="c">		 * Implementation of the setItem login; should be overwritten by storage engine.</span>
<span class="c">		 * @method _setItem</span>
<span class="c">		 * @param key {String} Required. The key used to reference this value.</span>
<span class="c">		 * @param data {Object} Required. The data to storage at key.</span>
<span class="c">		 * @return {Boolean} True when successful, false when size QUOTA exceeded.</span>
<span class="c">		 * @protected</span>
<span class="c">		 */</span>
		<span class="nx">_setItem</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">key</span><span class="o">,</span> <span class="nx">data</span><span class="o">)</span> <span class="o">{</span>
			<span class="nx">_logOverwriteError</span><span class="o">(</span><span class="s1">&#39;_setItem&#39;</span><span class="o">);</span>
			<span class="k">return</span> <span class="s1">&#39;&#39;</span><span class="o">;</span>
		<span class="o">}</span>
	<span class="o">};</span>

	<span class="nx">YL</span><span class="o">.</span><span class="nx">augmentProto</span><span class="o">(</span><span class="nx">YU</span><span class="o">.</span><span class="nx">Storage</span><span class="o">,</span> <span class="nx">YU</span><span class="o">.</span><span class="nx">EventProvider</span><span class="o">);</span>
<span class="o">}</span>

<span class="o">}());</span>
</pre></div>

                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_animation.html" title="animation">animation</a></li>
                                <li class=""><a href="module_autocomplete.html" title="autocomplete">autocomplete</a></li>
                                <li class=""><a href="module_button.html" title="button">button</a></li>
                                <li class=""><a href="module_calendar.html" title="calendar">calendar</a></li>
                                <li class=""><a href="module_carousel.html" title="carousel">carousel</a></li>
                                <li class=""><a href="module_charts.html" title="charts">charts</a></li>
                                <li class=""><a href="module_colorpicker.html" title="colorpicker">colorpicker</a></li>
                                <li class=""><a href="module_connection.html" title="connection">connection</a></li>
                                <li class=""><a href="module_container.html" title="container">container</a></li>
                                <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
                                <li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
                                <li class=""><a href="module_datatable.html" title="datatable">datatable</a></li>
                                <li class=""><a href="module_datemath.html" title="datemath">datemath</a></li>
                                <li class=""><a href="module_dom.html" title="dom">dom</a></li>
                                <li class=""><a href="module_dragdrop.html" title="dragdrop">dragdrop</a></li>
                                <li class=""><a href="module_editor.html" title="editor">editor</a></li>
                                <li class=""><a href="module_element.html" title="element">element</a></li>
                                <li class=""><a href="module_element-delegate.html" title="element-delegate">element-delegate</a></li>
                                <li class=""><a href="module_event.html" title="event">event</a></li>
                                <li class=""><a href="module_event-delegate.html" title="event-delegate">event-delegate</a></li>
                                <li class=""><a href="module_event-mouseenter.html" title="event-mouseenter">event-mouseenter</a></li>
                                <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
                                <li class=""><a href="module_get.html" title="get">get</a></li>
                                <li class=""><a href="module_history.html" title="history">history</a></li>
                                <li class=""><a href="module_imagecropper.html" title="imagecropper">imagecropper</a></li>
                                <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
                                <li class=""><a href="module_json.html" title="json">json</a></li>
                                <li class=""><a href="module_layout.html" title="layout">layout</a></li>
                                <li class=""><a href="module_logger.html" title="logger">logger</a></li>
                                <li class=""><a href="module_menu.html" title="menu">menu</a></li>
                                <li class=""><a href="module_paginator.html" title="paginator">paginator</a></li>
                                <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
                                <li class=""><a href="module_profilerviewer.html" title="profilerviewer">profilerviewer</a></li>
                                <li class=""><a href="module_progressbar.html" title="progressbar">progressbar</a></li>
                                <li class=""><a href="module_resize.html" title="resize">resize</a></li>
                                <li class=""><a href="module_selector.html" title="selector">selector</a></li>
                                <li class=""><a href="module_slider.html" title="slider">slider</a></li>
                                <li class="selected"><a href="module_storage.html" title="Storage">Storage</a></li>
                                <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
                                <li class=""><a href="module_swf.html" title="swf">swf</a></li>
                                <li class=""><a href="module_swfdetect.html" title="swfdetect">swfdetect</a></li>
                                <li class=""><a href="module_swfstore.html" title="swfstore">swfstore</a></li>
                                <li class=""><a href="module_tabview.html" title="tabview">tabview</a></li>
                                <li class=""><a href="module_treeview.html" title="treeview">treeview</a></li>
                                <li class=""><a href="module_uploader.html" title="uploader">uploader</a></li>
                                <li class=""><a href="module_yahoo.html" title="yahoo">yahoo</a></li>
                                <li class=""><a href="module_yuiloader.html" title="yuiloader">yuiloader</a></li>
                                <li class=""><a href="module_yuitest.html" title="yuitest">yuitest</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="YAHOO.util.Storage.html" title="YAHOO.util.Storage">YAHOO.util.Storage</a></li>
                                <li class=""><a href="YAHOO.util.StorageEngineGears.html" title="YAHOO.util.StorageEngineGears">YAHOO.util.StorageEngineGears</a></li>
                                <li class=""><a href="YAHOO.util.StorageEngineHTML5.html" title="YAHOO.util.StorageEngineHTML5">YAHOO.util.StorageEngineHTML5</a></li>
                                <li class=""><a href="YAHOO.util.StorageEngineKeyed.html" title="YAHOO.util.StorageEngineKeyed">YAHOO.util.StorageEngineKeyed</a></li>
                                <li class=""><a href="YAHOO.util.StorageEngineSWF.html" title="YAHOO.util.StorageEngineSWF">YAHOO.util.StorageEngineSWF</a></li>
                                <li class=""><a href="YAHOO.util.StorageEvent.html" title="YAHOO.util.StorageEvent">YAHOO.util.StorageEvent</a></li>
                                <li class=""><a href="YAHOO.util.StorageManager.html" title="YAHOO.util.StorageManager">YAHOO.util.StorageManager</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="gears_init.js.html" title="gears_init.js">gears_init.js</a></li>
                                <li class="selected"><a href="Storage.js.html" title="Storage.js">Storage.js</a></li>
                                <li class=""><a href="StorageEngineGears.js.html" title="StorageEngineGears.js">StorageEngineGears.js</a></li>
                                <li class=""><a href="StorageEngineHTML5.js.html" title="StorageEngineHTML5.js">StorageEngineHTML5.js</a></li>
                                <li class=""><a href="StorageEngineKeyed.js.html" title="StorageEngineKeyed.js">StorageEngineKeyed.js</a></li>
                                <li class=""><a href="StorageEngineSWF.js.html" title="StorageEngineSWF.js">StorageEngineSWF.js</a></li>
                                <li class=""><a href="StorageEvent.js.html" title="StorageEvent.js">StorageEvent.js</a></li>
                                <li class=""><a href="StorageManager.js.html" title="StorageManager.js">StorageManager.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2009 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">
    ALL_YUI_PROPS = [{"access": "protected", "host": "YAHOO.util.StorageEngineKeyed", "name": "_addKey", "url": "YAHOO.util.StorageEngineKeyed.html#method__addKey", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "CE_CHANGE", "url": "YAHOO.util.Storage.html#property_CE_CHANGE", "type": "property"}, {"access": "", "host": "YAHOO.util.Storage", "name": "CE_READY", "url": "YAHOO.util.Storage.html#property_CE_READY", "type": "property"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_cfg", "url": "YAHOO.util.Storage.html#property__cfg", "type": "property"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_clear", "url": "YAHOO.util.Storage.html#method__clear", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "clear", "url": "YAHOO.util.Storage.html#method_clear", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_createValue", "url": "YAHOO.util.Storage.html#method__createValue", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "DELIMITER", "url": "YAHOO.util.Storage.html#property_DELIMITER", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageManager", "name": "get", "url": "YAHOO.util.StorageManager.html#method_get", "type": "method"}, {"access": "private", "host": "YAHOO.util.StorageManager", "name": "_getClass", "url": "YAHOO.util.StorageManager.html#method__getClass", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_getItem", "url": "YAHOO.util.Storage.html#method__getItem", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "getItem", "url": "YAHOO.util.Storage.html#method_getItem", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "getName", "url": "YAHOO.util.Storage.html#method_getName", "type": "method"}, {"access": "private", "host": "YAHOO.util.StorageManager", "name": "_getStorageEngine", "url": "YAHOO.util.StorageManager.html#method__getStorageEngine", "type": "method"}, {"access": "private", "host": "YAHOO.util.StorageManager", "name": "_getValidLocation", "url": "YAHOO.util.StorageManager.html#method__getValidLocation", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_getValue", "url": "YAHOO.util.Storage.html#method__getValue", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "hasKey", "url": "YAHOO.util.Storage.html#method_hasKey", "type": "method"}, {"access": "protected", "host": "YAHOO.util.StorageEngineKeyed", "name": "_indexOfKey", "url": "YAHOO.util.StorageEngineKeyed.html#method__indexOfKey", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "isReady", "url": "YAHOO.util.Storage.html#property_isReady", "type": "property"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_key", "url": "YAHOO.util.Storage.html#method__key", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "key", "url": "YAHOO.util.Storage.html#method_key", "type": "method"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "key", "url": "YAHOO.util.StorageEvent.html#property_key", "type": "property"}, {"access": "protected", "host": "YAHOO.util.StorageEngineKeyed", "name": "_keyMap", "url": "YAHOO.util.StorageEngineKeyed.html#property__keyMap", "type": "property"}, {"access": "protected", "host": "YAHOO.util.StorageEngineKeyed", "name": "_keys", "url": "YAHOO.util.StorageEngineKeyed.html#property__keys", "type": "property"}, {"access": "", "host": "YAHOO.util.Storage", "name": "length", "url": "YAHOO.util.Storage.html#property_length", "type": "property"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_location", "url": "YAHOO.util.Storage.html#property__location", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageManager", "name": "LOCATION_LOCAL", "url": "YAHOO.util.StorageManager.html#property_LOCATION_LOCAL", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageManager", "name": "LOCATION_SESSION", "url": "YAHOO.util.StorageManager.html#property_LOCATION_SESSION", "type": "property"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_name", "url": "YAHOO.util.Storage.html#property__name", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "newValue", "url": "YAHOO.util.StorageEvent.html#property_newValue", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "oldValue", "url": "YAHOO.util.StorageEvent.html#property_oldValue", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageManager", "name": "register", "url": "YAHOO.util.StorageManager.html#method_register", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_removeItem", "url": "YAHOO.util.Storage.html#method__removeItem", "type": "method"}, {"access": "protected", "host": "YAHOO.util.StorageEngineKeyed", "name": "_removeKey", "url": "YAHOO.util.StorageEngineKeyed.html#method__removeKey", "type": "method"}, {"access": "protected", "host": "YAHOO.util.Storage", "name": "_setItem", "url": "YAHOO.util.Storage.html#method__setItem", "type": "method"}, {"access": "", "host": "YAHOO.util.Storage", "name": "setItem", "url": "YAHOO.util.Storage.html#method_setItem", "type": "method"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "source", "url": "YAHOO.util.StorageEvent.html#property_source", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "storageArea", "url": "YAHOO.util.StorageEvent.html#property_storageArea", "type": "property"}, {"access": "protected", "host": "YAHOO.util.StorageEngineSWF", "name": "_swf", "url": "YAHOO.util.StorageEngineSWF.html#property__swf", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "type", "url": "YAHOO.util.StorageEvent.html#property_type", "type": "property"}, {"access": "", "host": "YAHOO.util.StorageEvent", "name": "url", "url": "YAHOO.util.StorageEvent.html#property_url", "type": "property"}];
</script>
</body>
</html>
